package com.txy.alth.divide;

public class Pow {
    //计算x的n次幂
    public static int pow(int x, int n) {
//        if(n==0) return 1;
        if(n==1) return x;
        int half = pow(x, n/2);
        if(n%2 ==0) {
            return half*half;
        }else {
            return half*half*x;
        }
    }

    public static void main(String[] args) {
        System.out.println(pow(2,10));
    }
}
